/* Override for the open function */
static int v4l2_open(struct inode *inode, struct file *filp)
{
	struct video_device *vdev;
	int ret = 0;

	/* Check if the video device is available */
	mutex_lock(&videodev_lock);
	vdev = video_devdata(filp);
	/* and increase the device refcount */
	video_get(vdev);
	mutex_unlock(&videodev_lock);

	if (vdev->fops->open) {
		if (video_is_registered(vdev))
			ret = vdev->fops->open(filp);
	}

	/* decrease the refcount in case of an error */
	if (ret)
		video_put(vdev);
	return ret;
}

